From 01e86fb4a54b801a9b8124455611c312e5de4af0 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Mon, 14 Aug 2023 15:04:45 +0700 Subject: google sign in --- src/pages/api/auth/[...nextauth].js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/pages/api/auth/[...nextauth].js') diff --git a/src/pages/api/auth/[...nextauth].js b/src/pages/api/auth/[...nextauth].js index 6cc8a101..b11ed097 100644 --- a/src/pages/api/auth/[...nextauth].js +++ b/src/pages/api/auth/[...nextauth].js @@ -1,3 +1,4 @@ +import odooApi from '@/core/api/odooApi' import NextAuth from 'next-auth/next' import GoogleProvider from 'next-auth/providers/google' @@ -10,20 +11,20 @@ export default NextAuth({ ], callbacks: { async jwt({ token, account }) { - // Persist the OAuth access_token to the token right after signin if (account) { token.accessToken = account.access_token } return token }, async session({ session, token, user }) { - // Send properties to the client, like an access_token from a provider. session.accessToken = token.accessToken + const params = { + access_token: session.accessToken + } + const data = await odooApi('POST', '/api/v1/user/validate-sso', params) + session.odooUser = data.user return session } }, - secret:process.env.JWT_SECRET - // pages:{ - // signIn: '/login', - // } + secret: process.env.JWT_SECRET }) -- cgit v1.2.3